package com.woniuxy.microcurrentserver.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniuxy.bean.current.PageInfos;
import com.woniuxy.microcurrentserver.entity.CurrentFundHistory;
import com.woniuxy.microcurrentserver.entity.CurrentFundInfo;
import com.woniuxy.microcurrentserver.dao.CurrentFundInfoDao;
import com.woniuxy.microcurrentserver.service.CurrentFundInfoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Set;

/**
 * (CurrentFundInfo)表服务实现类
 *
 * @author makejava
 * @since 2021-04-08 14:40:02
 */
@Service("currentFundInfoService")
public class CurrentFundInfoServiceImpl implements CurrentFundInfoService {
    @Resource
    private CurrentFundInfoDao currentFundInfoDao;


    /**
     * 通过code查询单条数据
     *
     * @param code
     * @return 实例对象
     */
    @Override
    public CurrentFundInfo queryByCode(String code,Integer id) {


        return this.currentFundInfoDao.queryByCode(code,id);
    }

    /**
     * 查询多条数据
     *
     * @return 对象列表
     */
    @Override
    public PageInfo<CurrentFundInfo> queryAllByLimit(Integer page,String name) {
        PageHelper.startPage(page,10);
        List<CurrentFundInfo> currentFundInfos = this.currentFundInfoDao.queryAllByLimit(name);
        PageInfo<CurrentFundInfo> currentFundInfoPageInfo = new PageInfo<>(currentFundInfos);
        return  currentFundInfoPageInfo;
    }

    /**
     * 新增数据
     *
     * @param currentFundInfo 实例对象
     * @return 实例对象
     */
    @Override
    public boolean insert(CurrentFundInfo currentFundInfo) {
        int i = this.currentFundInfoDao.insert(currentFundInfo);
        return i>0;
    }

    /**
     * 修改数据
     *
     * @param currentFundInfo 实例对象
     * @return 实例对象
     */
    @Override
    public boolean update(CurrentFundInfo currentFundInfo) {

        return this.currentFundInfoDao.update(currentFundInfo)>0;
    }

    /**
     * 通过code删除数据
     *
     * @return 是否成功
     */
    @Override
    public boolean delete(PageInfos pageInfos) {

        return this.currentFundInfoDao.delete(pageInfos) > 0;
    }

    @Override
    public List<CurrentFundHistory> queryHistory(String code) {

        return this.currentFundInfoDao.queryHistory(code);
    }

    @Override
    public List<CurrentFundInfo> queryFundByCodeSet(Set<String> codes) {
        return this.currentFundInfoDao.queryFundByCodeSet(codes);
    }
}
